;
define(function (require, exports, module) {
    var base = require("base");
    var init = function (num) {
        require("../topMenu/topMenu.css"),
        $("#header").html(require("../topMenu/topMenu.html"));
        initEvent(num);
        loadCurrentUserInfo();
        /*inquireCurrentOperationList();*/
    };
    var inquireCurrentOperationList = function(){
        base.fnAjax({
            action: 'inquireCurrentOperationList.json',
            async:false,
            version: 'v3.0',
            fnSuccess: function (data) {
                if (data.status == 200) {
                    for(var i=0;i<data.datas.length;i++){
                        var permission = data.datas[i];
                        var permissionId = permission.permissionId;
                        permissionId = permissionId.substring(2,permissionId.length);
                        $(".topMenu").find("li[permissionId='"+permissionId+"'],a[permissionId='"+permissionId+"']").removeClass("none");
                        $(".menuc").find("a[permissionId='"+permissionId+"']").removeClass("none").addClass("block");
                    }
                    //$('#currentUserName').text(data.datas[0].name);
                } else {
                    base.alert(3, data.message);
                }
            }
        });
    };
    var loadCurrentUserInfo = function () {
        base.fnAjax({
            action: 'inquireCurrentUserInfo.json',
            async:false,
            version: 'v3.0',
            fnSuccess: function (data) {
                if (data.status == 200) {
                    $('#currentUserName').text(data.datas[0].fullName);
                } else {
                    base.alert(3, data.message);
                }
            }
        });
    }

    var initEvent = function (num) {
        $(".topMenu_hover:eq(" + num + ")").addClass("topMenu_selected");
        $("ul .topMenu_hover").on("click", function () {
            var location = $(this).children().attr("href");
            window.location.href = location;
        });
        // 退出登录
        $("#user_logout").click(function () {
            base.clearData("sid");//存sessionUuid
            base.openUrl("../login/login.html");
        });
        //下拉信息
        $(".leave").mouseenter(function () {
            $(".topMenu_user_set_menu").css("display", "none");
            var slideDown2 = $("#topMenu_userName_menu");
            slideDown2.css("display", "block");

            $(".leave").unbind("mouseleave").mouseleave(function () {
                time = setTimeout(function () {
                    slideDown2.css("display", "none");
                }, 2000);
            })
            slideDown2.unbind("mouseenter").mouseenter(function () {
                clearTimeout(time);
            });
            slideDown2.unbind("mouseleave").mouseleave(function () {
                slideDown2.css("display", "none");
            });

        });
    };
    return {
        init: init
    }
});